package cn.tudu.boot25.controller;

import cn.tudu.boot25.entity.Hero;
import cn.tudu.boot25.mapper.HeroMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {
    //登录
    @Autowired
    HeroMapper mapper;
    @RequestMapping("/reg")
    @ResponseBody
   public String reg(Hero hero){
        mapper.reg(hero);
       return "注册成功";
   }
   @RequestMapping("/delete")
   @ResponseBody
   public String delete(String name){
        mapper.delete(name);
        return "删除成功";
   }
   @RequestMapping("/update")
   @ResponseBody
    public String update(Hero hero){
        mapper.update(hero);
        return "更改成功" ;
    }
    @RequestMapping("/select")
    @ResponseBody
    public String select(){
        List<Hero> list = mapper.select();
        return list.toString();
    }
}
